'use strict';
const { Service } = require('egg');
const fs  = require('fs')
class MediaService extends Service {
  async deleteMedia({url,filename}){
    console.log("删除文件",url)
    if(url){
      const resutl = {code:1,msg:"删除成功"};
      url = url.replace("static/","")
      try{
        fs.rmSync(this.config.static.dir+url);
        return resutl;
      }catch(err){
        console.log(err)
        // resutl.code = 0;
        // resutl.msg = "删除本地文件失败"+JSON.stringify(err);
        return resutl;
      }
    }
  }
}

module.exports = MediaService;
